<?php
/*
 * 职位控制器
 * @author     Leo
 * @Created  2016/6/17
 */
namespace Admin\Controller;
// use Think\Controller;
class JobController extends CommonController {
	public function index(){
		//职位管理首页
	$job=D('Home/Jobs'); //实例化数据库
	$count = D('Home/Jobs as a')->join('v5_companys as b ON a.com_id=b.com_id')->field('a.job_id,a.com_id,b.comname,a.positionname,a.salarymin,a.salarymax,a.workyear,a.education,a.is_hot,a.pubtime')->count();// 查询满足要求的总记录数
	$this->assign('count',$count); //输出记录数到模板
	$Page  = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
	$show  = $Page->show();// 分页显示输出
	// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
	//$list = $amd->field('userid,rid,username,nick,logintime,loginip,status')->where('userid>0')->order('userid')->limit($Page->firstRow.','.$Page->listRows)->select();
	$list=D('Home/Jobs as a')->join('v5_companys as b ON a.com_id=b.com_id')
	->field('a.job_id,a.com_id,b.comname,a.positionname,a.salarymin,a.salarymax,a.workyear,a.education,a.is_hot,a.pubtime')
	->order('a.job_id')->limit($Page->firstRow.','.$Page->listRows)->select();
	//var_dump($list);exit;
	$this->assign('list',$list);// 赋值数据集
	$this->assign('page',$show);// 赋值分页输出
			$this->display();
 }


public function joblist(){
 		 //详细查看工作
 			 $com=D('Home/Jobs');//实例化工作model
 			 $job_id=I('get.id');    //定义com_id数值.用id掩护防止sql抓包!!id为pid get方式的伪装
			 $jlist=D('Home/Jobs as a')->join('v5_companys as b ON a.com_id=b.com_id')->where(["job_id"=>$job_id])->order('a.job_id')->find();
 			 $this->assign('jlist',$jlist); //查询职位资料
 			 $this->display(joblist);//输出到details
 	 }

 public function del(){
	 	//职位管理删除
		$job=D('Home/Jobs'); //实例化数据库
		$job_id=I('get.id');
		if($job->delete($job_id)){
				 $this->redirect('Admin/job/index');exit;
		 }else{
				$this->error('删除失败','',2);
		 }
   }
}
